package com.qf.web;

import com.qf.service.StudentDeleteService;
import com.qf.service.impl.StudnetDeleteServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/delete")
public class DeleteId extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        String id = req.getParameter("id");
        int i = Integer.parseInt(id);
        StudentDeleteService studentDeleteService=new StudnetDeleteServiceImpl();
        int i1 = studentDeleteService.deleteIa(i);
        if (i1>0){
            req.getRequestDispatcher("admin/left.jsp").forward(req,resp);
            }else {
                req.setAttribute("cuo","删除失败");
                req.getRequestDispatcher("admin/cuo.jsp").forward(req,resp);
            }
        }


    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
